<?php
//echo 3;
include("ldap_novell.php");

$novell = new ldap_novell;                                        // Crea Objeto Novell.
$novell->autenticacion($_POST["login"],$_POST["passwd"]);         // Pide Autenticacion del usuario
If ($novell->valido){                                             // Comprueba si es valido.
        setcookie("novell_usuario",$novell->usuario,0,"/");
        setcookie("novell_password",$novell->password,0,"/");
        setcookie("novell_nombre",$novell->nombre,0,"/");
        setcookie("novell_email",$novell->email,0,"/");
        setcookie("novell_acceso","0000",0,"/");
        setcookie("novell_valido","SI",0,"/");

        include("../../inc/psa_conect.php");

        $sql = "select * from usuarios where usuario = '".$_POST["login"]."'";
        $result = mysql_query($sql,$link);
        if ($row = mysql_fetch_array($result)){
           setcookie("novell_acceso",$row[acceso],0,"/");
           header("Location:".$posi.$_POST["pagina"]);
           exit;
        }else{
           setcookie("novell_usuario"," " ,0,"/");
           setcookie("novell_password"," ",0,"/");
           setcookie("novell_nombre"," "  ,0,"/");
           setcookie("novell_email",""    ,0,"/");
           setcookie("novell_valido","NO" ,0,"/");
           setcookie("novell_acceso","",0,"/");

           if (!isset($_POST["error"])){
              header("Location:.");
           }

           header("Location:".$_POST["error"]);
           exit;
        }

        header("Location:".$_POST["pagina"]);
        exit;
}else{
        setcookie("novell_usuario"," " ,0,"/");
        setcookie("novell_password"," ",0,"/");
        setcookie("novell_nombre"," "  ,0,"/");
        setcookie("novell_email",""    ,0,"/");
        setcookie("novell_valido","NO" ,0,"/");

        header("Location:".$_POST["error"]);
}
if (!isset($_POST["error"])){
     header("Location:../../");
}

?>
